package com.itheima.excel;

import cn.hutool.json.JSON;
import cn.hutool.json.JSONUtil;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.read.listener.ReadListener;

import java.io.File;

public class ExcelDemo {
    public static void main(String[] args) {
        read();
    }

    private static void read() {
        File file = new File("D:\\web-programmer\\web\\【扩展】excel导入导出\\资料\\03. excel文件\\用户信息.xlsx");
        EasyExcel.read(file, User.class, new ReadListener<User>() {
            @Override
            public void invoke(User user, AnalysisContext analysisContext) {
                System.out.println(JSONUtil.toJsonStr(user));
            }

            @Override
            public void doAfterAllAnalysed(AnalysisContext analysisContext) {
                System.out.println("读取完毕");
            }
        }).sheet().doRead();
    }
}
